import request from '@/utils/request'

// 1. 根据查询参数获取员工列表
export const reqGetEmployee = (params) => {
  return request.get('/sys/user', {
    params
  })
}

// 2. 批量导出Excel
export const reqExportEmployee = () => {
  return request.get('/sys/user/export', {
    // 告知服务端需要二进制流数据
    responseType: 'blob'
  })
}

// 3. 下载导入员工模板文件
export const reqEmployeeTemplate = () => {
  return request({
    url: '/sys/user/import/template',
    method: 'get',
    responseType: 'blob'
  })
}

// 4. 批量上传员工(Excel)
export const reqUploadEmployee = (data) => {
  return request.post('/sys/user/import', data) // data是一个formData对象
}

// 5. 删除员工
export const reqDelEmployee = (id) => {
  return request.delete(`/sys/user/${id}`)
}

// 6. 新增一个员工
export const reqAddEmployee = (data) => {
  return request.post('/sys/user', data)
}

// 7. 获取员工详情
export const reqEmployeeDetail = (id) => {
  return request.get(`/sys/user/${id}`)
}

// 8. 编辑一个员工
export const reqEditEmployee = (data) => {
  return request.put(`/sys/user/${data.id}`, data)
}

// 9. 分配-员工-角色
export const reqAssignRole = (data) => {
  return request.put('/sys/user/assignRoles', data)
}
